<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    <script>
        function judgeNum(num){
            var x = String(num).indexOf('.') + 1   //小数点的位置
            var y = String(num).length - x     //小数的位数
            if(x){//num是小数
                alert(`小数:${num}有${y}几位小数`)
            }else{//num不是小数
                alert(`整数：${num}`)
            }
        }
        judgeNum(0.123456789)
    </script>
</head>
<body>
    
</body>
</html>
